package com.osell.selection.ui.main;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import com.osell.selection.data.network.entity.Category;

import java.util.List;

public class HomeProductsPagerAdapter extends FragmentPagerAdapter {

    private List<Category> mData;

    HomeProductsPagerAdapter(FragmentManager fm, List<Category> categories) {
        super(fm);
        mData = categories;
    }

    @Override
    public Fragment getItem(int position) {
        return position == 0 ? new RecommendProductsFragment() : HomeProductsFragment.newInstance(mData.get(position).id);
    }

    @Override
    public int getCount() {
        return mData == null ? 0 : mData.size();
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return mData.get(position).name;
    }
}
